package next.apps.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

public class UniqueId {
    public static String generateID() throws NoSuchAlgorithmException {
        UUID uuid = UUID.randomUUID();
        String uuidStr = uuid.toString();

        long timestamp = System.currentTimeMillis();

        String idStr = uuidStr + timestamp;

        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] hashBytes = md.digest(idStr.getBytes());

        StringBuilder sb = new StringBuilder();
        for (byte b : hashBytes) {
            sb.append(String.format("%02x", b));
        }
        return sb.toString();
    }
}
